package com.lpf.config;

import com.lpf.filter.MyTypeFilter;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;

/**
 * 配置类==配置文件
 */
@Configuration  // 告诉Spring这是一个配置类

// 方式一
//@ComponentScan(value = "com.lpf")

//方式二：扫描的时候排除哪些
//@ComponentScan(value = "com.lpf", excludeFilters = {
//        @Filter(type = FilterType.ANNOTATION, classes = {Controller.class, Service.class})
//})

// 方式三：扫描的时候包含哪些
//@ComponentScan(value = "com.lpf", includeFilters = {
//        @Filter(type = FilterType.ANNOTATION, classes = {Controller.class})
//}, useDefaultFilters = false)

// 方式四：配置多个
@ComponentScans(
        value = {
                @ComponentScan(value = "com.lpf", includeFilters = {
                        //@Filter(type = FilterType.ANNOTATION, classes = {Controller.class})
                        //@Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {BookService.class})
                        @Filter(type = FilterType.CUSTOM, classes = {MyTypeFilter.class})
                }, useDefaultFilters = false)
        }
)

/**
 * @ComponentScan
 *      value：指定要扫描的包
 *      excludeFilters = Filter[] ：指定扫描的时候按照什么规则排除那些组件
 *      includeFilters = Filter[] ：指定扫描的时候只需要包含哪些组件
 *      FilterType.ANNOTATION：按照注解
 *      FilterType.ASSIGNABLE_TYPE：按照给定的类型
 *      FilterType.ASPECTJ：使用ASPECTJ表达式
 *      FilterType.REGEX：使用正则指定
 *      FilterType.CUSTOM：使用自定义规则
 */

public class MainConfig {

}
